/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.araujogrosz.fractalcore;

import java.awt.Graphics;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

/**
 *
 * @author renatogrosz@gmail.com
 */
public class JanelaFractal extends JFrame implements ImageDrawner {
    
	private static final long serialVersionUID = 1L;
	private BufferedImage buf;
    private ImagePainter painter;
    private CalcFract calcFract;

    JanelaFractal(int imageSize, ColorMatrix colorMatrix) {
        this.calcFract = new CalcFract(imageSize);
        painter = new ImagePainter(imageSize, colorMatrix);
        this.calcFract.setPrinter(painter);
        buf = painter.getBuf();
        this.calcFract.setIterations(1000);
        calcFract.calc();
        this.setSize(imageSize + WindowParam.LEFT_BORDER + 5, imageSize + WindowParam.WINDOW_TITLE_HEIGHT + 5);
        
        MouseWheelListener mouseLister = new DefaultMouseListener(calcFract, calcFract, this);        
        super.addMouseWheelListener(mouseLister);
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(buf, 5, 25, this);
    }

    @Override
    public void drawImage() {
        super.getGraphics().drawImage(buf, WindowParam.LEFT_BORDER + 5, WindowParam.WINDOW_TITLE_HEIGHT + 5, this);        
    }

    
}
